package com.bayihouse.model.vo;


import com.bayihouse.model.entity.Community;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommunityVO implements Serializable {
    private static final long serialVersionUID = -906736472108743112L;
    private Long id;

    /**
     * 社区名称
     */
    private String name;

    /**
     * 社区地址
     */
    private String address;

    private String detail;

    private String createTime;

    public static CommunityVO objToVo(Community community) {
        CommunityVO communityVO = new CommunityVO();
        BeanUtils.copyProperties(community, communityVO);
        Date createTime1 = community.getCreateTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(createTime1);
        communityVO.setCreateTime(format);
        return communityVO;
    }


    public static Community voToObj(CommunityVO communityVO) {
        Community community = new Community();
        BeanUtils.copyProperties(communityVO, community);
        return community;
    }
}
